//
//  MyTabBar.m
//  微博
//
//  Created by 杨佩璋 on 15/6/29.
//  Copyright (c) 2015年 杨佩璋. All rights reserved.
//

#import "MyTabBar.h"

@interface MyTabBar ()
@property(nonatomic,retain)UIButton *plusButton;
@end
@implementation MyTabBar

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        UIButton *middleButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [middleButton setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button"] forState:UIControlStateNormal];
        [middleButton setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button_highlighted"] forState:UIControlStateHighlighted];
        [middleButton setImage:[UIImage imageNamed:@"tabbar_compose_icon_add"] forState:UIControlStateNormal];
        [middleButton setImage:[UIImage imageNamed:@"tabbar_compose_icon_add_highlighted"] forState:UIControlStateHighlighted];
        middleButton.size = middleButton.currentBackgroundImage.size;
        [middleButton addTarget:self action:@selector(plusClick) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:middleButton];
//        middleButton.backgroundColor = [UIColor redColor];
        self.plusButton = middleButton;
        
    }
    return self;
}


//-(void)layoutSubviews
//{
//    [super layoutSubviews];
//    NSLog(@"%@",self.subviews);
//    self.plusButton.centerX = self.width *0.5;
//    self.plusButton.centerY = self.height *0.5;
//    CGFloat width = self.width/5;
//    NSArray *array = self.subviews;
//    NSInteger index = 0;
//    for (UIView *view in array) {
//        Class class = NSClassFromString(@"UITabBarButton");
//        if ([view isKindOfClass:class]) {
//            view.width = width;
//            view.x = index *width;
//            index++;
//            if (index==2) {
//                index++;
//            }
////            view.backgroundColor = [UIColor redColor];
//        }
//    }
//}

//- (void)plusClick
//{
//    if ([self.delegate respondsToSelector:@selector(tabBarDidClickPlusButton:)]) {
//        [self.delegate tabBarDidClickPlusButton:self];
//    }
//}

@end
